<template>
  <div>
    <span style="margin-left:120px;margin-right: 20px;width: 150px;display: inline-block;">请选择咨询师</span>
    <el-select v-model="get" placeholder="请选择" @change="getType()" style="width: 19%;">
      <el-option
        v-for="item in manageAll"
        :label="item.Name"
        :value="item.id"
        :key="item.name">
        {{item.Name}}
      </el-option>
    </el-select>
      <el-button type="primary" icon="el-icon-search" size="mini" @click="getManage">获取咨询师</el-button>
    <el-button type="primary" icon="el-icon-search" size="mini" @click="submitManage">全部提交</el-button>
    <el-table v-loading="loading" :data="studentquestionList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="学生提问" align="center" prop="question" />
      <el-table-column label="咨询师回答" align="center" prop="answer" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="submitOne(scope.row)"
            v-hasPermi="['system:studentquestion:edit']"
          >提交</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {manageGet,manageList,addList} from "@/api/system/manage";
import {listStudentquestion} from "@/api/system/studentQuestion";

export default {
  name: "Studentquestion",
  props:['value'],
  data() {
    return {
      submitOne:{},
      submitDate:{},
      key:"",
      get:"",
      list:[],
      catelist:[],
      //咨询师姓名
      manage:{},
      manageAll:[],
      manageAlls:{},
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      studentquestionList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        studentId: null,
        question: null,
        answer: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList()
  },
  methods: {
    submitOne(row){
      this.submitOne=row
      addList(row,this.get).then(response=>{
      })
    },
    submitManage(){
     addList(this.submitDate,this.get).then(response => {
      });
    },
    handleSelectionChange(getDate){
      this.submitDate=getDate
      console.log(this.submitDate)
    },
    getType(){
      console.log(this.get)
    },
    getList(){
      manageList().then(response => {
        console.log(response)
        this.list=response.rows
      });
      this.loading = true;
      listStudentquestion(this.queryParams).then(response => {
        this.studentquestionList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getManage(){
      this.manageAll=[]
      console.log(this.list)
      for (let user of this.list){
        this.manage.Name=user.nickName
        this.manage.id=user.userId
        console.log(this.manage)
        if (user.deptId==100){
          this.manageAll.push(this.manage)
        }
        this.manage={
          Name:undefined,
          id:undefined
        }
      }
      console.log(this.manageAll)
    }

  }
};
</script>
